home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2001 December / pcwk12201b.iso / Wersje pelne i specjalne / Ghostscript 7.0 / gs700w32.exe / gs7.00 / lib / stcolor.ps < prev    next >
Text File  |  2000-09-19  |  6KB  |  174 lines

  1. % Copyright (C) 1995 Aladdin Enterprises.  All rights reserved
  2. % This file is part of AFPL Ghostscript.
  3. % AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  4. % distributor accepts any responsibility for the consequences of using it, or
  5. % for whether it serves any particular purpose or works at all, unless he or
  6. % she says so in writing.  Refer to the Aladdin Free Public License (the
  7. % "License") for full details.
  8. % Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. % in a plain ASCII text file named PUBLIC.  The License grants you the right
  10. % to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. % conditions described in the License.  Among other things, the License
  12. % requires that the copyright notice and this notice be preserved on all
  13. % copies.
  14.  
  15. % $Id: stcolor.ps,v 1.2 2000/09/19 18:29:11 lpd Exp $
  16. % stcolor.ps
  17. % Epson Stylus-Color Printer-Driver
  18.  
  19. % The purpose of this file is to configure the stcolor-printer driver
  20.  
  21. %
  22. % It is useless and dangerous to interpret the following code with anything
  23. % else than Ghostscript, so this condition is verified first. If this fails
  24. % a message is send to the output. If this message bothers you, remove it,
  25. % but I prefer to know why the device-setup failed.
  26.  
  27. statusdict begin product end
  28. dup (Ghostscript) eq 1 index (Aladdin Ghostscript) eq or
  29. exch (AFPL Ghostscript) eq or{
  30.  
  31. % fetch the current device-parameters this is specific for Ghostscript.
  32.  
  33.   /STCold currentdevice getdeviceprops .dicttomark def
  34.  
  35. % Any Ghostscript-Driver has a Name, verify that the selected device is
  36. % stcolor, otherwise nothing than another message will be produced.
  37.  
  38.   STCold /Name get (stcolor) eq {
  39.  
  40. %
  41. % The main thing this file does, is to establish transfer-functions.
  42. % Here are two predefined arrays for 360x360Dpi and for 720x720DpI.
  43. % If resolution is 360x720 or 720x360 the average is used. You may
  44. % want to define other arrays here.
  45. %
  46.  
  47.      /STCdeftransfer [ 0.0 1.0 ] def
  48.  
  49.      /STCKtransfer360 [
  50.        0.0000 0.0034 0.0185 0.0377 0.0574 0.0769 0.0952 0.1147
  51.        0.1337 0.1540 0.1759 0.1985 0.2209 0.2457 0.2706 0.2949
  52.        0.3209 0.3496 0.3820 0.4145 0.4505 0.4907 0.5344 0.5840
  53.        0.6445 0.7093 0.8154 0.9816 0.9983 0.9988 0.9994 1.0000
  54.      ] def
  55.  
  56.      /STCKtransfer720 [
  57.        0.0000 0.0011 0.0079 0.0151 0.0217 0.0287 0.0354 0.0425
  58.        0.0492 0.0562 0.0633 0.0700 0.0766 0.0835 0.0900 0.0975
  59.        0.1054 0.1147 0.1243 0.1364 0.1489 0.1641 0.1833 0.2012
  60.        0.2217 0.2492 0.2814 0.3139 0.3487 0.3996 0.4527 0.5195
  61.      ] def
  62.  
  63. % compute the resolution
  64.  
  65.      STCold /HWResolution get dup
  66.      0 get exch 1 get mul sqrt /STCdpi exch def
  67.  
  68. % pick the colormodel
  69.      STCold /ProcessColorModel get /STCcolor exch def
  70.  
  71.  
  72.      mark % prepare stack for "putdeviceprops" 
  73.  
  74. % warn for BitsPerPixel=30 with fsrgb
  75.      STCcolor /DeviceRGB eq STCold /BitsPerPixel get 32 eq and 
  76.      {
  77.        (%%[ stcolor.ps: inefficient RGB-setup, recommend BitsPerPixel=24 ]%%\n)
  78.        print
  79.       } if
  80.  
  81. % if the Dithering-Method is default (gscmyk), change it to fscmyk
  82. % this is achieved by pushing a name/value-pair onto the stack
  83. % if the selected algorithm uses another ProcessColorModel, it is necessary
  84. % to change the Value of STCcolor according to the new algorithm.
  85.  
  86.      STCold /Dithering get (gscmyk) eq 
  87.      { 
  88.         /Dithering (hscmyk) % preferred dithering-method
  89.      } if % might be necessary to change STCcolor too
  90.  
  91. %
  92. % select the array according to the resolution
  93. %
  94.      STCdpi 359.0 lt 
  95.      { STCdeftransfer }
  96.      { STCdpi 361.0 lt
  97.        { STCKtransfer360 }
  98.        { STCdpi 719.0 gt
  99.          { STCKtransfer720 }
  100.          {
  101.            STCKtransfer360 length STCKtransfer720 length eq
  102.            {
  103.              0 1 STCKtransfer360 length 1 sub 
  104.              {
  105.                dup dup 
  106.                STCKtransfer360 exch get 
  107.                exch STCKtransfer720 exch get 
  108.                add 2.0 div 
  109.                STCKtransfer360 3 1 roll put
  110.              } for
  111.            }if
  112.            STCKtransfer360
  113.          } ifelse
  114.        }ifelse
  115.      } ifelse
  116.      /STCtransfer exch def
  117.  
  118. %
  119. % Add the arrays. With Version 1.17 and above, it seems to be 
  120. % a good idea, to use the transfer-arrays as coding-arrays too.
  121. %
  122.  
  123. %
  124. % RGB-Model requires inversion of the transfer-arrays
  125. %
  126.      STCcolor /DeviceRGB eq 
  127.      {
  128.         /RGBtransfer STCtransfer length array def
  129.         0 1 STCtransfer length 1 sub
  130.         {
  131.           dup RGBtransfer length 1 sub exch sub exch 
  132.           STCtransfer exch get 1.0 exch sub
  133.           RGBtransfer 3 1 roll put
  134.         } for
  135.  
  136.         /Rtransfer RGBtransfer
  137.         /Gtransfer RGBtransfer
  138.         /Btransfer RGBtransfer
  139.  
  140.         /Rcoding   RGBtransfer
  141.         /Gcoding   RGBtransfer
  142.         /Bcoding   RGBtransfer
  143.  
  144.      }{
  145.  
  146.        /Ctransfer STCtransfer
  147.        /Mtransfer STCtransfer
  148.        /Ytransfer STCtransfer
  149.        /Ktransfer STCtransfer
  150.  
  151.        /Ccoding   STCtransfer
  152.        /Mcoding   STCtransfer
  153.        /Ycoding   STCtransfer
  154.        /Kcoding   STCtransfer
  155.  
  156.      } ifelse
  157.  
  158.      counttomark 0 ne 
  159.         {currentdevice putdeviceprops pop}{cleartomark}ifelse
  160.  
  161. % decativate predefined correction
  162.  
  163.      {} dup dup currenttransfer setcolortransfer
  164.  
  165.   }{
  166.     (%%[ stcolor.ps: currentdevice is not stcolor - ignored ]%%\n) print
  167.   } ifelse
  168. }{
  169.   (%%[ stcolor.ps: not interpreted by AFPL Ghostscript - ignored ]%%\n) print
  170. } ifelse
  171.